package cn.tiga.feignclient;

import cn.tiga.domain.User;
import feign.hystrix.FallbackFactory;

import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallback implements FallbackFactory<UserFeignClient> {

    //日志打印器
    @Override
    public UserFeignClient create(Throwable throwable) {
        // 1.打印接口错误，方便查找错误
        throwable.printStackTrace();
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L, "触发熔断！", "熔断触发服务不可用！");
            }
        };
    }
}